Google 工作表 - 不同列上的 GROUP BY 和 ORDER BY
Google Sheets - GROUP BY and ORDER BY on different column
我得到了一个table这种格式
Name Datum
A 01.01.2019
B 17.03.2020
C 18.03.2020
C 01.04.2020
我从这个查询中得到这个 table 输出:
=QUERY(Anrufe!:00;"Select A,B where A is not null ORDER BY B ASC label A 'Name', B 'Datum'")
我正在尝试更改查询,以便它执行分组依据。它应该是这样的
Name Datum count
A 01.01.2019 1
B 17.03.2020 1
C 01.04.2020 2
但是当我添加分组依据并向 select 添加聚合函数时,它仍然会抛出错误。
=QUERY(Anrufe!:00;"Select A,B, min(B) where A is not null group by A ORDER BY B ASC label A 'Name', B 'Datum'")
我希望查询选择 B 列中最年轻的日期。但似乎 QUERY-Parser 强制我将 B 列添加到分组依据中。这导致了同样的问题,我必须手动计算具有相同名称的记录。
有人知道如何解决吗?
已经检查了这些链接:
Google Sheets query - Multiple “where” conditions with “group by” and “order by”
I got this message (CANNOT_GROUP_WITHOUT_AGG) from a simple query
我想你想要这个:
=QUERY(Anrufe!:00,"Select A,min(B),count(A) where A is not null group by A ORDER BY min(B) ASC label A 'Name', min(B) 'Datum'")
我得到了一个table这种格式
Name Datum
A 01.01.2019
B 17.03.2020
C 18.03.2020
C 01.04.2020
我从这个查询中得到这个 table 输出:
=QUERY(Anrufe!:00;"Select A,B where A is not null ORDER BY B ASC label A 'Name', B 'Datum'")
我正在尝试更改查询,以便它执行分组依据。它应该是这样的
Name Datum count
A 01.01.2019 1
B 17.03.2020 1
C 01.04.2020 2
但是当我添加分组依据并向 select 添加聚合函数时,它仍然会抛出错误。
=QUERY(Anrufe!:00;"Select A,B, min(B) where A is not null group by A ORDER BY B ASC label A 'Name', B 'Datum'")
我希望查询选择 B 列中最年轻的日期。但似乎 QUERY-Parser 强制我将 B 列添加到分组依据中。这导致了同样的问题,我必须手动计算具有相同名称的记录。
有人知道如何解决吗? 已经检查了这些链接:
Google Sheets query - Multiple “where” conditions with “group by” and “order by”
I got this message (CANNOT_GROUP_WITHOUT_AGG) from a simple query
我想你想要这个:
=QUERY(Anrufe!:00,"Select A,min(B),count(A) where A is not null group by A ORDER BY min(B) ASC label A 'Name', min(B) 'Datum'")